/*
 * RtpPackerFactory.cpp
 *
 *  Created on: 2019年3月28日
 *      Author: terry
 */

#include "RtpPackerFactory.h"

//#include "CRtpPacker.h"
//#include "H264RtpPacker.h"
//#include "H265RtpPacker.h"
//#include "AacRtpPacker.h"

#include "CRtpUnPacker.h"
#include "H264RtpUnPacker.h"
#include "H265RtpUnPacker.h"
#include "AacRtpUnPacker.h"

#include "CodecName.h"
#include "TStringUtil.h"


namespace av
{

RtpPackerFactory::RtpPackerFactory()
{
}

RtpPackerFactory::~RtpPackerFactory()
{
}
/*
RtpPacker* RtpPackerFactory::createPacker(MediaType mediaType, const std::string& codec)
{
    if (codec == "H264")
    {
        return new H264RtpPacker();
    }
    else if (codec == "H265" || codec == "HEVC")
    {
        return new H265RtpPacker();
    }
    else if (codec == "AAC" || codec == "MP4A" || comn::StringUtil::icompare(codec, "MPEG4-GENERIC") == 0)
    {
        return new AacRtpPacker();
    }

    int mediaCodec = CodecName::parse(codec);
    CRtpPacker* packer(new CRtpPacker());
    packer->setCodec(mediaCodec);
    return packer;
}

RtpPacker* RtpPackerFactory::createPacker(MediaType mediaType, MediaCodec codec)
{
    if (codec == MEDIA_CODEC_H264)
    {
        return new H264RtpPacker();
    }
    else if (codec == MEDIA_CODEC_HEVC)
    {
        return new H265RtpPacker();
    }
    else if (codec == MEDIA_CODEC_AAC)
    {
        return new AacRtpPacker();
    }

    CRtpPacker* packer(new CRtpPacker());
    packer->setCodec(codec);
    return packer;
}
*/

RtpUnPacker* RtpPackerFactory::createUnPacker(MediaType mediaType, const std::string& codec)
{
    if (codec == "H264")
    {
        return new H264RtpUnPacker();
    }
    else if (codec == "H265" || codec == "HEVC")
    {
        return new H265RtpUnPacker();
    }
    else if (codec == "AAC" || codec == "MP4A")
    {
        return new AacRtpUnPacker();
    }

    CRtpUnPacker* unpacker(new CRtpUnPacker());
    return unpacker;
}



} /* namespace av */
